
package Objects;

import GameEngine.GameConstants.Effect;
import GameEngine.GameConstants.Graphic;
import GameEngine.GameConstants.Material;
import GameEngine.GameConstants.Thing;
import GameEngine.LevelInitializer;
import GameEngine.Vector;

/**
 *
 * @author mhfowler
 */
public class BombDropper extends GameObject {



    // instance variables
    private int mushRate;
    private boolean isOn = true;

    
    public BombDropper(Vector d, Vector cen, Vector s) {
        super(d, cen, s, Graphic.FISH);
        material = Material.BOMB;
        isTangible = false;
    }


    /* set the strenght of the fan */
    public void setMushRate(int rate) {
        mushRate = rate;
    }


     /** this method will be called on every object at the beginning of every iteration. In this method
     * particular objects may do specific things, such as arbitrarily update their own attributes based
     * on some correlation to their lifetime (how long they've existed...eg chompers updating their deltaPosition
     * up or down), or even causing an effect on other objects. But every object must iterate through the
     * list of persistent effects on them and receive them.
     */
    @Override
    public void nextIteration() {
        // first apply persistent
        super.applyPersistent();
        if (isOn && lifetime%60 == 0) {
            graph = Graphic.BOMBDROP;
            Bomb toCreate = (Bomb) LevelInitializer.objectConstructor(Thing.BIGBOMB, new Vector(0,1), center, new Vector(50,50));
            lev.createObject(toCreate);
        }
        else {
            graph = Graphic.FISH;
        }
        // then do physics
        super.doPhysics();
        // then undo persitent
        super.cancelPersistent();
    }


    @Override
    public void receiveEffect(Effect e, Vector m, int power) {
        switch (e) {
            case TRANSMUTE:
                isOn = !isOn;
                break;
            case SPEED:
                changed = true;
                mushRate += power;
                break;
            case SLOW:
                changed = true;
                mushRate -= power;
                break;
            default:
                super.receiveEffect(e, m, power);
                break;
        }
    }



        @Override
    public void collide(GameObject o) {
        // not much happens
    }






}
